module ysyx_22040213_booth(
	input  [131:0] mul_x,
	input  [2:0] mul_y,
	output [131:0] mul_res
);
  wire y_add,y,y_sub;
  wire sel_negative,sel_double_negative,sel_positive,sel_double_positive;
  wire [131:0] x_double,x_neg,x_neg_double;
  wire [3:0] res_sel;

  assign {y_add,y,y_sub} = mul_y;

  assign sel_negative =  y_add & (y & ~y_sub | ~y & y_sub);
  assign sel_positive = ~y_add & (y & ~y_sub | ~y & y_sub);
  assign sel_double_negative =  y_add & ~y & ~y_sub;
  assign sel_double_positive = ~y_add &  y &  y_sub;

  assign x_double = {{mul_x[130:0]},1'b0};
  assign x_neg = ~mul_x + 132'b1;
  assign x_neg_double = ~x_double + 132'b1;

  assign res_sel = {{sel_negative},{sel_positive},{sel_double_negative},{sel_double_positive}};

  MuxKey #(4, 4, 132) i0 (mul_res, res_sel, {
  	4'b1000, x_neg,
	4'b0100, mul_x,
	4'b0010, x_neg_double,
	4'b0001, x_double
  });

endmodule
